
$(function() {
	// validate signup form on keyup and submit
	var validator = $("#form_add").validate({
		rules: {
			code: {
				required: true,
				minlength: 2
			},
			name: {
				required: true,
				minlength: 2
			}
		},
		messages: {
		},
		errorPlacement: function(label, element) {
			if (/^birthdate/.test(element[0].name)) {
				label.insertAfter("#birthdateYear");
			} else {
				label.insertAfter(element);
			}
		},
		// specifying a submitHandler prevents the default submit, good for the demo
		submitHandler: function() {
			alert("submitted");
			return $("#form_add").submit();
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("checked");
		}
	});

	$('textarea').css("width", 300);
});
